package process

import (
	"example/pkg/db"
	"example/pkg/logger"
	"example/pkg/message"
	"fmt"
	"strings"
)

type Reader interface {
	Read()
}

type LogProcess struct {
	Rc     chan string           //读取到解析传递数据
	Wc     chan *message.Message //解析到写入模块
	Reader logger.Reader
	Writer db.Writer
}

func (l *LogProcess)Process()  {
	for v := range l.Rc {

		b := strings.Trim(v, "")
		if  b== "" {
			continue
		}

		msg,err :=  message.ParseMessage(v)
		if err != nil {
			fmt.Println(err)
			continue
		}


		l.Wc <- msg
	}
}


